<div>
	<div id="order-html">
    <section class="order">
        <div class="order-top"><span   data-l="1018"></span></div>
		<div class="bank100"></div>
        <div class="order-mode"></div>
        <div class="order-mode2"></div>
        
        <script id="select-buy-js3" type="text/html">
            <div class="order-t1 cf">
                <div class="fl"><span data-l="1050"></span> <span class="red">{{order_info.shop_table_name}}</span></div>
                 <div class="oh f-right"><i   data-l="1019"></i> <span class="red sum">{{total_money}}</span></div>                
            </div>
            <div class="order-t1 cf">
                <div class="fl"><em  data-l="1003"></em><span class="red yidian">{{number1}}</span></div>
                <div class="oh f-right"><em data-l="1020"></em><span class="red">{{number2}}</span></div>
            </div>

            <div class="order-bank"></div>
            <div class="order-t3 cf">
                <div class="fl f1 f-30 lang"  data-l="1021"></div>
                <div class="oh f2">
                    <div class="fr">
                        <a href="#!main/note"><svg class="g2" ><use xlink:href="#f_5"></use></svg></a>
                    </div>
                    <div class="oh f-30 f-right" id="order-note"></div>
                </div>
            </div>
            
            <!--<div class="order-waimai cf">
				<div class="weui-cells_checkbox">
			        <label class="weui-cell weui-check__label" for="s11" style="padding: 0.2rem 0.1rem;">
			          <div class="weui-cell__bd f-right">
			            <p>standard is dealt for u.</p>
			          </div>
			          <div class="weui-cell__hd" style="padding-right: 0;">
			            <input type="checkbox" class="weui-check" name="checkbox1" id="s11" checked="checked">
			            <i class="weui-icon-checked"></i>
			          </div>
			          
			        </label>
		      </div>
            </div>-->

			{{if my_number}}
				<div class="order-bank"></div>
				<div class="order-box-name f-30 cf">
                		<div class="oh"><span data-l="1007"></span> {{my_number}}</div>
                </div>
                {{each my_list as v i}}
                	{{if i==member_id}}
                	{{if v[0]}}
                	<div class="user-box">
                	<div class="n pad-20 f-right"><span data-l="1061"></span> <span class="red">{{i}}</span></div>
                	<ul class="car-ul ">
                	{{each v as vv ii}}                	
                    {{if vv.status==1}}                    	
                        <li class="cf" data-id="{{vv.goods_cate_id}}" data-cart_id="{{vv.cart_id}}">
                            <div class="sp1">{{vv.goods_name}} 
                            	{{if vv.goods_spec_name}}<span class="c999">[{{vv.goods_spec_name}}]</span>{{/if}}
                            	{{if vv.goods_taste_name}}<span class="c999">[{{vv.goods_taste_name}}]</span>{{/if}}                            	
                            </div>
                            <div class="sp2">{{vv.goods_price}}</div>
                            <div class="sp3">                            	
                                 <div class="addright cf" data-parent-id="{{vv.goods_cate_id}}"  data-cart_id="{{vv.cart_id}}" data-id="{{vv.goods_id}}" data-num="{{vv.count}}" data-price="{{vv.goods_price}}" data-specid="{{vv.spec_id}}" data-goodsspecid="{{vv.goods_spec_id}}">
                                    <div class="p p1"><i></i><svg class="g1" ><use xlink:href="#f_4"></use></svg></div>
                                    <span class="g3">{{vv.count}}</span>
                                    <div class="p p2"><i></i><svg class="g2" ><use xlink:href="#f_5"></use></svg></div>
                                </div>
                            </div>
                            {{each vv.garnish_ids as vvv iii}}
                            	<div class="clear"></div>
                            	<div class="mag-l-20 {{if iii==0}}mag-t-20{{/if}}">
                            		<div style="height: 0; border:1px dashed #fafafa"></div>
	                            	<div class="cf pad-10 mag-t-5 mag-b-5"  style="padding-right: 0;">
	                            		<div class="sp1" style="width: 3.2rem;"><span class="f-24">{{vvv.goods_garnish_name}}</span></div>
			                            <div class="sp2" style="position: relative;">{{vvv.goods_price}} <span style="position: absolute; left: 100%; bottom: -0.03rem; white-space: nowrap; margin-left: 0.1rem; font-size: 0.20rem; color: #aaa;">x{{vv.count}}</span></div>
			                            <div class="sp3">                            	
			                                 <div class="addright_child cf" data-num="{{vvv.count}}" data-cart_id="{{vv.cart_id}}"  data-garnish_id ="{{vvv.garnish_id }}">
			                                    <div class="p p1"><i></i><svg class="g1" ><use xlink:href="#f_4"></use></svg></div>
			                                    <span class="g3">{{vvv.count}}</span>
			                                    <div class="p p2"><i></i><svg class="g2" ><use xlink:href="#f_5"></use></svg></div>
			                                </div>
			                            </div>
	                            	</div>
                            	</div>
                            {{/each}}
                            <!--{{if vv.garnish_ids[0]}}
                            	<div class="clear"></div>
                            	<div >
                            		<div style="height: 0; border:1px dashed #fafafa"></div>
                            		<div class="f-right red mag-t-20"><span data-l="1019"></span> {{vv.total_price}}</div>
                            	</div>
                            {{/if}}-->
                            
                        </li>
                    {{/if}}
                    {{/each}}
                    </ul>
                    </div>
                    {{/if}}
                   {{/if}}
                {{/each}}

            {{/if}}
           

			{{if th_number}} 
				<div class="order-bank"></div>
				<div class="order-box-name f-30"><span data-l="1008"></span> {{th_number}}</div>
                {{each my_list as v i}}
                	{{if i!=member_id}}
                	{{if v[0]}}
                	<div class="user-box">
                	<div class="n pad-20 f-right"><span data-l="1061"></span> <span class="red">{{i}}</span></div>
                	<ul class="car-ul ">
                	{{each v as vv ii}}                	
	                    {{if vv.status==1}}                    	
	                        <li class="cf" data-id="{{vv.goods_cate_id}}" data-cart_id="{{vv.cart_id}}">
	                            <div class="sp1">{{vv.goods_name}} 
	                            	{{if vv.goods_spec_name}}<span class="c999">[{{vv.goods_spec_name}}]</span>{{/if}}
	                            	{{if vv.goods_taste_name}}<span class="c999">[{{vv.goods_taste_name}}]</span>{{/if}}   
	                            </div>
	                            <div class="sp2">{{vv.goods_price}}</div>
	                            <div class="sp3">                            	
	                                 <div class="addright cf" >
	                                    <div class="p p1 disable"><i></i><svg class="g1" ><use xlink:href="#f_4"></use></svg></div>
	                                    <span class="g3">{{vv.count}}</span>
	                                    <div class="p p2 disable"><i></i><svg class="g2" ><use xlink:href="#f_5"></use></svg></div>
	                                </div>
	             
	                            </div>
	                            
	                            
	                               {{each vv.garnish_ids as vvv iii}}
		                            	<div class="clear"></div>
		                            	<div class="mag-l-20 {{if iii==0}}mag-t-20{{/if}}">
		                            		<div style="height: 0; border:1px dashed #fafafa"></div>
			                            	<div class="cf pad-10 mag-t-5 mag-b-5"  style="padding-right: 0;">
			                            		<div class="sp1" style="width: 3.2rem;"><span class="f-24">{{vvv.goods_garnish_name}}</span></div>
					                            <div class="sp2" style="position: relative;">{{vvv.goods_price}} <span style="position: absolute; left: 100%; bottom: -0.03rem; white-space: nowrap; margin-left: 0.1rem; font-size: 0.20rem; color: #aaa;">x{{vv.count}}</span></div>
					                            <div class="sp3">                            	
					                                 <div class="addright_child cf">
					                                    <div class="p p1 disable"><i></i><svg class="g1" ><use xlink:href="#f_4"></use></svg></div>
					                                    <span class="g3">{{vvv.count}}</span>
					                                    <div class="p p2 disable"><i></i><svg class="g2" ><use xlink:href="#f_5"></use></svg></div>
					                                </div>
					                            </div>
			                            	</div>
		                            	</div>
		                            {{/each}}
		                            <!--{{if vv.garnish_ids[0]}}
		                            	<div class="clear"></div>
		                            	<div >
		                            		<div style="height: 0; border:1px dashed #fafafa"></div>
		                            		<div class="f-right red mag-t-20"><span data-l="1019"></span> {{vv.total_price}}</div>
		                            	</div>
		                            {{/if}}-->
	                            
	                            
	                        </li>
	                    {{/if}}
                    {{/each}}
                    </ul>
                    </div>
                    {{/if}}
                   	{{/if}}
                {{/each}}

            {{/if}}
            
            <div class="order-bank"></div>
        
        <div class="order-price red f-30 f-right">
            <i data-l="1024"></i>：<span class="sum">{{total_money}}</span>
        </div>
        </script>

        

        <div class="order-bank"></div>
        <div class="bank100"></div>
        <div class="bank100"></div>
        <div class="order-bon f-30">
            <a href="#!/main/select" class="a1 lang"  data-l="1025"></a>
            <a href="javascript:;" class="a2 lang" id="order-a2"  data-l="1026"></a>
        </div>

    </section>

<Script>
  
    $(".order-bon .a2").click(function () {
        if ($(this).hasClass("null")) return false;
        global_ajax(jsonpath + "put_shop_order_confirm", { remarks: localStorage.getItem("note") }, function (e) {
            Q.go("main/finish")
        })
    })
	

    var setselect_item1=function(){
    	global_ajax(jsonpath + "get_shop_buy_page", {type:1}, function (e) {
        //初始化已选数据
                cart_obj = {
                	"total_money":0,
                	"my_number": 0,
                	"th_number": 0,
                	"open_other":false,
                    "member_id": getCookie("yingsoft_home_member_id"),
                    "my_list": {},
                    "cart_id_list": {},
                    "order_info":e.result.order_info
                }
    
                $(".title1").text(cart_obj.order_info.shop_table_name);//设置title
				$.each(e.result.cart_goods_list, function (i0, v0) {
					cart_obj.my_list[i0]=[];
	                $.each(v0, function (i, v) {
	                	if(v.status==1){
		                	//添加名称 规格名称
		                	if(v.goods_id== undefined || caidan_json[v.goods_id]==undefined) return true;
		                    var name1 = caidan_json[v.goods_id].goods_name,
		                    	guige = v.spec_id!=0 ? guige1_json[v.spec_id].goods_spec_name :null,
		            			kouwei = v.taste_id!=0 ? kouwei1_json[v.taste_id].goods_taste_name:null;
		                    	
		                    	v["goods_name"]=name1;
		                    	v["goods_spec_name"]=guige;
		                    	v["goods_taste_name"]=kouwei;
		                    	
		                    	$.each(v.garnish_ids, function (ii, vv) {
		                    		var name2 = peicai_json[vv.garnish_id].goods_garnish_name;
		                    		vv["goods_garnish_name"]=name2;
		                    	});
		                    	//console.log(v.garnish_ids)
		                    	
		                  
		                    cart_obj.my_list[i0].push(v)
		                    cart_obj.cart_id_list[v.cart_id]=1;
						}
                  })//匹配数据
                 })//匹配数据
 				//$(".carbuy .car-tit .fr").click();
                marry_fun();
        })
    }
        

    //匹配以选择数据
    var marry_fun = function (data) {    	
		//处理新插入的数据
		var newd1=true//是否新增数据
		if (data!=undefined)
        {
        	var data1 = JSON.parse(data).data,
        	slist=cart_obj.my_list[data1.member_id];
        	
			if(slist!=undefined)
			{
				var sss=getjsons(slist,data1.cart_id,'cart_id'),
					sssid=getindex(slist,data1.cart_id,'cart_id')
        		if(sss.cart_id!=undefined)
				{
 					newd1=false;
 					var myobj=$(".my-list li[data-goodsspecid="+ data1.goods_spec_id +"]");
					if(data1.count==0){
						//删除数据
						var ind=getindex2(cart_obj.my_list,data1.goods_spec_id,'goods_spec_id',data1.member_id,'member_id');
						cart_obj.my_list.baoremove(ind);
						myobj.remove()
					}else{
						slist[sssid]=setaddss(data1)//更新数量
						console.log(slist[sssid])
						//更新界面							
						//myobj.find(".addright").attr("data-num", data1.count);
						//myobj.find(".addright").find(".g3").text(data1.count);
					}
				}
				
			}
			//判断是否新增数据
			if(newd1){                    	
                //添加名称 规格名称                    	
	                if(!!!cart_obj.my_list[setaddss(data1).member_id]) cart_obj.my_list[setaddss(data1).member_id]=[];		                
                	cart_obj.my_list[setaddss(data1).member_id].push(setaddss(data1))
			}
        	//更新界面数字状态；
        }
		
		function setaddss(data1){
			var ss=data1;   
            var name1 = caidan_json[ss.goods_id].goods_name,
            	guige = ss.spec_id!=0 ? guige1_json[ss.spec_id].goods_spec_name :null,
	            kouwei = ss.taste_id!=0 ? kouwei1_json[ss.taste_id].goods_taste_name:null;
            	ss["goods_name"]=name1;
            	ss["goods_spec_name"]=guige;
            	ss["goods_taste_name"]=kouwei;
            	
            	$.each(ss.garnish_ids, function (ii, vv) {
            		var name2 = peicai_json[vv.garnish_id].goods_garnish_name;
            		vv["goods_garnish_name"]=name2;
            	});
            	return ss;
		}
		
		
          //购物车列表
    	$(".menu-left li i,.select-buy .left .gw i,.select-buy .left .gw em").text("");
    	var objs=$(".menu-right .item"),
			nums=objs.find(".addright").attr("data-num",0);
    	cart_obj.th_number=0;
    	cart_obj.my_number=0;
    	cart_obj.total_money=0;
    	cart_obj.number1=0;
    	cart_obj.number2=0;
        $.each(cart_obj.my_list, function (ii, vv) {
            
            	 //判断是否有其他用户
            	if(cart_obj.member_id != ii){
            		cart_obj.open_other=true;	
            		$.each(vv, function (i, v) {
            			if(v.status==1){
            			cart_obj.th_number += Number(v.count);
            			cart_obj.number1+=Number(v.count);
            			cart_obj.total_money = accAdd(cart_obj.total_money, v.total_price)
            			}
            			if(v.status==2 || v.status==3){
            				cart_obj.number2+=Number(v.count);
            			}
            		})
            	}else{
            		$.each(vv, function (i, v) {
            			if(v.status==1){
                		cart_obj.my_number += Number(v.count);
                		cart_obj.number1+=Number(v.count);
                		//左侧分类列表
	                    var cate_id = $(".menu-left li[data-id=" + v.goods_cate_id + "] i").text();
	                    cate_id = cate_id != '' ? cate_id : 0
	                    var ss = accAdd(cate_id, v.count);
	                    if (ss > 0) {
	                        $(".menu-left li[data-id=" + v.goods_cate_id + "] i").text(ss);
	                    }
	                    //设置总价
	                    cart_obj.total_money = accAdd(cart_obj.total_money, v.total_price)

	                   }
            			if(v.status==2 || v.status==3){
            				cart_obj.number2+=Number(v.count);
            			}
                   })
            	}
            	//总价
            	

        })
        
        //格式化金额
        cart_obj.total_money=toFixed2(cart_obj.total_money, 2)
        $("#total_price span").text(cart_obj.total_money);
        
        //清空数据调用
        if (cart_obj.my_number == 0 && cart_obj.th_number == 0) {
        	$(".menu-right .item").removeClass("add")
        	$(".select-menu").removeClass("open-gwc");
        	$(".select-buy").removeClass("open");
        	$(".menu-right .item .g3").text(0);
		    $(".menu-right .item .addright").attr("data-num", 0);
        } 
        if (cart_obj.my_number > 0) {
            $(".select-buy").addClass("open");
            $(".select-buy .left .gw i").text(cart_obj.my_number);
        }
        if (cart_obj.th_number > 0) {
        	$(".car-box").removeClass("open-otehr"); 
            $(".select-buy").addClass("open");
            $(".select-buy .left .gw em").text(cart_obj.th_number);
        }else{
        	$(".car-box").addClass("open-otehr"); 
        }
        //
        console.log(cart_obj)
        
        //只有添加新数据才更新模板
        $(".order-mode").html(template("select-buy-js3", cart_obj));
        

        setlange_obj()//设置前端语言
        //更新备注
        $("#order-note").html(localStorage.getItem("note"))
        
    }

	setselect_item1();
	
	
</Script>
</div>
</div>